//
//  YCStatusCellHeadView.swift
//  swift微博
//
//  Created by 姚伟聪 on 15/12/22.
//  Copyright © 2015年 姚伟聪. All rights reserved.
//

import UIKit

class YCStatusCellHeadView: UIView {

    
    var status: YCStatus? {
    
        didSet{
            
            nameLab.text = status?.users?.screen_name
            
            if let imageStr = status?.users?.profile_image_url {
            
             iconView.sd_setImageWithURL(NSURL(string: imageStr))
            }
            
            verifiedView.image = status?.users?.verifiedImage
            
            vipView.image = status?.users?.mbrankImage
           
            
            
        
        }
    
    }
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        addUI()
        
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func addUI(){
    
        addSubview(iconView)
        addSubview(nameLab)
        addSubview(vipView)
        addSubview(timeLab)
        addSubview(souceLab)
        addSubview(verifiedView)
        
        iconView.ff_AlignInner(type: ff_AlignType.CenterLeft, referView: self, size: CGSize(width: 35, height: 35), offset: CGPoint(x: 8, y: 0))
    
        verifiedView.ff_AlignInner(type: ff_AlignType.BottomRight, referView: iconView, size: nil, offset: CGPoint(x: 8, y: 8))
        
        nameLab.ff_AlignHorizontal(type: ff_AlignType.TopRight, referView: iconView, size: nil, offset: CGPoint(x: 10, y: 0))
        
        
        vipView.ff_AlignHorizontal(type: ff_AlignType.CenterRight, referView: nameLab, size: CGSize(width: 14, height: 14), offset: CGPoint(x: 10, y: 0))
        
        timeLab.text = "刚刚"
      
        timeLab.ff_AlignHorizontal(type: ff_AlignType.BottomRight, referView: iconView, size: nil, offset: CGPoint(x: 10, y: 0))
        
      
        souceLab.text = "我的客户端"
        souceLab.ff_AlignHorizontal(type: ff_AlignType.CenterRight, referView: timeLab, size: nil, offset: CGPoint(x: 10, y: 0))
        
    }
    
    
    
    
    
    //MARK: - 懒加载
    //头像
    private lazy var iconView: UIImageView = {
        
        let imageView = UIImageView(image: UIImage(named: "avatar"))
        
        return imageView
        
    }()
    //名字
    private lazy var nameLab: UILabel = UILabel(fontSize: 14, textColor: UIColor.blackColor())
    //时间文本
    private lazy var timeLab: UILabel = UILabel(fontSize: 9, textColor: UIColor.orangeColor())
    //来源
    private lazy var souceLab: UILabel = UILabel(fontSize: 9, textColor: UIColor.grayColor())
    //Vip
    private lazy var vipView: UIImageView = UIImageView()
    //认证
    private lazy var verifiedView: UIImageView = UIImageView()

}
